
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// 设置Vue自带API自动引入(无需引入)
import AutoImport from "unplugin-auto-import/vite"
// 设置Antd按需引入
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import path  from "path";
// https://vitejs.dev/config/

export default defineConfig({
  plugins: [vue(),
    AutoImport({
      imports: ['vue'],
      dts: 'src/auto-import.d.ts',
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  resolve: {
    alias: {
      "@": path.join(__dirname, "./src")
    }
  },
  server: {
    host: "127.0.0.1", // 开发服务器的地址
    port: 5173,        // 开发服务器的端口号
    // 配置代理规则
    proxy: {
      '/api': {
        target: 'https://v.api.aa1.cn', // 目标服务器地址
        changeOrigin: true, // 是否改变源地址
        rewrite: (path) => path.replace(/^\/api/, ''), // 重写路径
      },
    },
  },
})
